﻿using System;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Util
{
    public class WebConnection<T> : RemoteConnection<T> where T : class
    {
        public WebConnection(string uri, TimeSpan? timeout = null) : base(uri, timeout)
        {
            //
        }

        protected override ChannelFactory<T> CreateFactory(string uri, TimeSpan timeout)
        {
            var binding = new WebHttpBinding()
            {
                SendTimeout = timeout,
                ReceiveTimeout = timeout,
                OpenTimeout = timeout,
                CloseTimeout = timeout,
            };

            return new WebChannelFactory<T>(binding, new Uri(uri));
        }
    }
}
